package com.xmall.controller.admin;

import com.xmall.bean.vo.BaseRespVo;
import com.xmall.bean.table.Admin;


import com.xmall.bean.vo.IssueList;
import com.xmall.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/admin")
public class AdminController {
    @Autowired
    AdminService adminService;
    @RequestMapping("list")

    public BaseRespVo selectAdmin(Integer page, Integer limit, String username, String sort, String order){

        IssueList<Admin> adminIssueList= adminService.selectAdmin(page,limit,username,sort,order);
        return BaseRespVo.ok(adminIssueList);

    }


    @RequestMapping("create")
    public BaseRespVo insertAdmin(@RequestBody Admin admin){

        Admin admin1 = adminService.insertAdmin(admin);

        return BaseRespVo.ok(admin1);
    }

    @RequestMapping("update")
    public BaseRespVo updateAdmin(@RequestBody Admin admin){

        Admin admin1 = adminService.updateAdmin(admin);

        return  BaseRespVo.ok(admin1);
    }

    @RequestMapping("delete")
    public BaseRespVo deleteAdmin(@RequestBody Admin admin){

        Integer i = adminService.deleteAdmin(admin);

        return BaseRespVo.ok(i);

    }
}
